package ru.royalgatemagazine.app;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.widget.Toast;

public class DialogGenerator {
	
	public static final int DIALOG_PROGRESS = 1;
	public static final int DIALOG_NOTIFICATION = 2;
	
	private DialogGenerator(){}
	
	public static final ProgressDialog createProgressTitledDialog(Context context, DialogGeneratorListener listener, int dialogId, String title, String text) {
		ProgressDialog dialog = new ProgressDialog(context);
		dialog.setTitle(title);
		dialog.setMessage(text);
		dialog.setCancelable(false);
		return dialog;
	}
	
	public static final AlertDialog createOneButtonDialog(Context context, DialogGeneratorListener listener, int dialogId, String title, String text, String buttonText) {
		AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
		if (title != null) {
			dialogBuilder.setTitle(title);
		}
		if (text != null) {
			dialogBuilder.setMessage(text);
		}
		if(buttonText==null){
			buttonText = "";
		}
		dialogBuilder.setPositiveButton(buttonText, listener);
		dialogBuilder.setOnCancelListener(listener);
		AlertDialog dialog = dialogBuilder.create();
		return dialog;
	}
	
	public static void showToast(Context context, int stringResource){
		Toast mToast = Toast.makeText(context, stringResource, Toast.LENGTH_LONG);
		mToast.show();
	}
	
	public static interface DialogGeneratorListener extends  DialogInterface.OnClickListener, DialogInterface.OnCancelListener{
	}
}
